# -*- coding: utf-8 -*-

import json
import time
import uuid

from bson.json_util import dumps
from pymongo import MongoClient


class MapService:
    client = MongoClient('127.0.0.1', 27018)

    def __init__(self):
        self.client = MongoClient('127.0.0.1', 27018)


    # 获取DJI单个国家的数据
    def queryDJIForCountry(self, countryCode):
        mongod = self.client['NoFly']
        collection = mongod['DjiAreas4']
        result = []
        for d in  collection.find({"sub_areas":{"$ne":None, "$exists": True },"country" : countryCode}):
            result.append(d)
        # result = dumps(collection.find().limit(100))  # 查询mongodb
        return json.dumps(result)
